function uploadImageSuccess(thumbnail, data) {
	$("#dialog-insert").modal('hide');
	vditor.get.insertValue("![image]("+thumbnail+")");
}

vditor = new Object();

vditor.get = {};

vditor.create = function(id, height, counter, hintList) {
	var host = $("#"+id).attr("data-host");
	$("#insert-image").attr("data-host", host)
	
	vditor.get = new Vditor(id, {
		after: undefined,
		  cache: {
	            enable: false,
	      },
	      classes: {
	            preview: "",
	      },
		  height: height,
		  width: 'auto',
		  placeholder:'请输入内容',
		  lang:'zh_CN',
		  counter: {
	            enable: true,
	            max: counter,
	        },
		  tab: '\t',
		  typewriterMode: true,
		  toolbar: [
	            "headings",
	            "bold",
	            "italic",
	            "strike",
	            "link",
	            "|",
	            "list",
	            "ordered-list",
	            "check",
	            "outdent",
	            "indent",
	            "|",
	            "quote",
	            "line",
	            "code",
	            "inline-code",
	            "insert-before",
	            "insert-after",
	            "|",
	            "record",
	            "table",
	  		    {  
	  			 tipPosition: 'ne',
	  			 name: 'network',
	  			 tip: '网络图片',  
	  			 icon: '<svg data-v-79c8069a="" aria-hidden="true" focusable="false" data-prefix="far" data-icon="images" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" class="svg-inline--fa fa-images fa-w-18"><path data-v-79c8069a="" fill="currentColor" d="M480 416v16c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V176c0-26.51 21.49-48 48-48h16v48H54a6 6 0 0 0-6 6v244a6 6 0 0 0 6 6h372a6 6 0 0 0 6-6v-10h48zm42-336H150a6 6 0 0 0-6 6v244a6 6 0 0 0 6 6h372a6 6 0 0 0 6-6V86a6 6 0 0 0-6-6zm6-48c26.51 0 48 21.49 48 48v256c0 26.51-21.49 48-48 48H144c-26.51 0-48-21.49-48-48V80c0-26.51 21.49-48 48-48h384zM264 144c0 22.091-17.909 40-40 40s-40-17.909-40-40 17.909-40 40-40 40 17.909 40 40zm-72 96l39.515-39.515c4.686-4.686 12.284-4.686 16.971 0L288 240l103.515-103.515c4.686-4.686 12.284-4.686 16.971 0L480 208v80H192v-48z" class=""></path></svg>',  
	  			 click: () => {  
	  				var $vditor = $("#vditor");
	  				$vditor.attr("data-dialog-t-title", "插入图片");
	  				$vditor.attr("data-dialog-t-name", "图片地址(或数据)");
	  				$vditor.attr("data-dialog-p-hint", "请输入图片地址(http://或data:)");
	  				$vditor.attr("data-dialog-prompt", "url");
	  				dialog.input($vditor[0], function(obj) {
	  					var url = $(obj).attr("data-obj-url");
	  					if (url.startWith("http")||url.startWith("data")) {
	  						vditor.get.insertValue("![image]("+url+")");
	  					} else {
	  						toast.info("图片不正确", undefined, 1500);
	  					}
	  				});
	  			 }
	  			},
	            "|",
	            "undo",
	            "redo",
	            "|",
	            "edit-mode",
	            {
	                name: "more",
	                toolbar: [
	                    "both",
	                    "code-theme",
	                    "content-theme",
	                    "export",
	                    "outline",
	                    "preview",
	                    "devtools",
	                ],
	        }],
		  mode: "sv",
		  hint: {
			  delay: 200,
			  extend: [
				{
					  key:"$",
					  hint:function(e){
						  return hintList;
					  	},
					},
			  ],
		  },
	})
}

vditor.getValue = function() {
	return vditor.get.getValue();
}

vditor.getHTML = function() {
	return vditor.get.getHTML();
}

